﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

namespace WEALTH
{
    public partial class ListView : System.Web.UI.Page
    {
        public string strLeftmenu = string.Empty;
        ExcuteDao dao = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["listviewid"]) &&
                          !string.IsNullOrEmpty(Request.QueryString["menutype"]))
                {
                    SetLeftMenu();
                    loaderData(Convert.ToInt32(Request.QueryString["listviewid"]));
                }
            }
        }

        //=============================================
        //函数名称:loaderData()
        //作    用:将查询到的内容绑定到控件上
        //=============================================
        private void loaderData(int listid)
        {
            DataTable dt = new DataTable();

            dt = dao.Get_ListText(listid);

            if (dt != null && dt.Rows.Count > 0)
            {
                lblTitle.Text = SpecialCharHandler.HtmlDiscode(dt.Rows[0]["listTitle"].ToString());
                lblDate.Text = dt.Rows[0]["listDate"].ToString();
                lblName.Text = SpecialCharHandler.HtmlDiscode(dt.Rows[0]["listFrom"].ToString());
                lblText.Text = SpecialCharHandler.HtmlDiscode(dt.Rows[0]["listText"].ToString());
            }
        }
        /// <summary>
        /// 设置左侧菜单
        /// </summary>
        private void SetLeftMenu()
        {
            string strmenutype = Request.QueryString["menutype"].ToString();

            DataTable dt = dao.Get_LeftMenuALL("", strmenutype);
            strLeftmenu = string.Empty;
            strLeftmenu += "<li id=\"one\" class=\"files\"><a href=\"#\">" + strmenutype + "</a><ul class=\"sub-menu\">";
            if (strmenutype.Equals("投资者教育"))
            {
                strLeftmenu += "<li><a href=\"Risk.aspx\" title=\"\"><em>01</em>在线风险测试</a></li>";
                strLeftmenu += "<li><a href=\"Assets.aspx\" title=\"\"><em>02</em>在线资产配置</a></li>";
                strLeftmenu += "<li><a href=\"ListView.aspx?listviewid=15&menutype=投资者教育\" title=\"\"><em>03</em>理财师的价值</a></li>";
                strLeftmenu += "<li><a href=\"#\" title=\"\"><em>04</em>在线理财师</a></li>";
                strLeftmenu += "<li><a href=\"MoneyManageOrder.aspx\" title=\"\"><em>05</em>预约理财师</a></li>";
                strLeftmenu += "<li><a href=\"#\" title=\"\"><em>06</em>理财计算器</a></li>";
            }
            else
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int intMenuID = Convert.ToInt32(dt.Rows[i]["MenuID"]);
                        string strmenuname = dt.Rows[i]["MenuName"].ToString();
                        DataTable menuDt = dao.Get_ListALL("", "", intMenuID, "");

                        if (menuDt.Rows.Count == 1)
                        {
                            int listid = Convert.ToInt32(menuDt.Rows[0]["listID"]);

                            strLeftmenu += "<li><a href=\"ListView.aspx?listviewid="
                            + listid + "&menutype=" + strmenutype + "\" title=\"\"><em>"
                            + (i + 1).ToString().PadLeft(2, '0') + "</em>" + strmenuname + "</a></li>";
                        }
                        else
                        {
                            strLeftmenu += "<li><a href=\"List.aspx?menuid="
                                + intMenuID + "&menutype=" + strmenutype + "\" title=\"\"><em>"
                                + (i + 1).ToString().PadLeft(2, '0') + "</em>" + strmenuname + "</a></li>";
                        }
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>企业文化</a></li>";
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>精英团队</a></li>";
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>公司新闻</a></li>";
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>合作伙伴</a></li>";
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>招贤纳士</a></li>";
                        //strLeftmenu += "<li><a href=\"#\" title=\"\"><em>01</em>联系我们</a></li>";
                    }
                }
            }
            strLeftmenu += "</ul></li>";
        }
    }
}